/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kenny.wiki.ejb.entity.facade;

import com.kenny.wiki.ejb.entity.TitleItem;
import com.kenny.wiki.ejb.entity.facade.remote.TitleItemFacadeRemote;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Kenny Lin
 */
@Stateless
public class TitleItemFacade extends AbstractFacade<TitleItem> implements TitleItemFacadeRemote {
    @PersistenceContext(unitName = "Kenny-Wiki-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public TitleItemFacade() {
        super(TitleItem.class);
    }

    public List<TitleItem> findByTitleId(int titleId){
        return getEntityManager().createNamedQuery("TitleItem.findByTitleIdAndTiDisplay")
                .setParameter("titleId", titleId).setParameter("tiDisplay", 1).getResultList();
    }

}
